using System;
using System.Reflection.Emit;
using Pine.SourceParser.Tree;

namespace Pine.CodeGen
{
	public static class ReturnEllipsisStatementCodeGenerator
	{
		public static void GenerateBytecode(Context ctx, Statement stmt)
		{
			ReturnEllipsisStatement ret = (ReturnEllipsisStatement) stmt;
			
			if (!(ret.e is CallExpression))
				throw new Exception("Expression in return... expr; must be a function call.");
			
			CallExpression call = (CallExpression) ret.e;
			
			CallExpressionCodeGenerator.GenerateBytecodeForList(ctx, call);
			
			ctx.il.Emit(OpCodes.Ret);
		}
	}
}

